<?php

namespace app\common\model\campus;

use app\common\model\BaseModel;
use app\common\model\Region as RegionModel;

/**
 * 校区专业模型
 * Class Shop
 * @package app\common\model\store
 */
class CoursesCategory extends BaseModel
{
    protected $name = 'campus_courses_category';

    /**
     * 关联校区表
     * @return \think\model\relation\hasOne
     */
    public function campus()
    {
        return $this->hasOne('Campus','campus_id','campus_id');
    }

    /**
     * 关联专业表
     * @return \think\model\relation\hasOne
     */
    public function category()
    {
        return $this->hasOne(\app\common\model\CoursesCategory::class,'courses_category_id','courses_category_id');
    }

    /**
     * 校区专业详情
     * @param $id
     * @return static
     */
    public static function detail($id)
    {
        /* @var $model self */
        $model = (new static)->with([
            'category',
            'campus',
        ])->whereIn('id', $id)
            ->find();
        if (empty($model)) {
            return $model;
        }
        // 整理商品数据并返回
        return $model;
    }

}